﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 生命体征测试仪
{
    public partial class formWorkLogin : formBase
    {
        public formWorkLogin()
        {
            InitializeComponent();
            numKey1.NumKey_BtnClicked += new 生命体征测试仪.NumKey.BtnClickHandle(InputNum);
            numKey1.Set1("下一项");
        }
        void InputNum(int n)
        {

            this.Invoke((EventHandler)(delegate
            {
                if (n == -2)
                {
                    if (curIndex == 0)
                    {
                        curIndex = 1;
                        tbName.BackColor = System.Drawing.Color.White;
                        tbPass.BackColor = System.Drawing.Color.Gold;
                    }
                    else
                    {
                        curIndex = 0;
                        tbName.BackColor = System.Drawing.Color.Gold;
                        tbPass.BackColor = System.Drawing.Color.White;
                    }
                    return;
                }
                if (curIndex == 0)
                {
                    if (n == -1)
                        tbName.Text = "";
                    else
                        tbName.AppendText(n.ToString());
                }
                else
                {
                    if (n == -1)
                        tbPass.Text = "";
                    else
                        tbPass.AppendText(n.ToString());
                }
                //                 if (n == -1)
                //                     tbPhone.Text = "";
                //                 else if (n == -2)
                //                     tbPhone.Text = tbPhone.Text.Substring(0, tbPhone.Text.Length - 1);
                //                 else
                //                     tbPhone.AppendText(n.ToString());
            }));
        }
        int curIndex = 0;
        private void formWorkLogin_Load(object sender, EventArgs e)
        {
            tbName.BackColor = System.Drawing.Color.Gold;
            tbPass.BackColor = System.Drawing.Color.White;
        }

        private void tbName_Click(object sender, EventArgs e)
        {
            curIndex = 0;
            tbName.BackColor = System.Drawing.Color.Gold;
            tbPass.BackColor = System.Drawing.Color.White;
        }

        private void tbPass_Click(object sender, EventArgs e)
        {
            curIndex = 1;
            tbName.BackColor = System.Drawing.Color.White;
            tbPass.BackColor = System.Drawing.Color.Gold;
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }
    }
}
